<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="${ctxPath}/assets/expand/images/jilu_icon.png" rel="icon">
    <title>${systemName}</title>
    <link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="${ctxPath}/assets/common/module/admin.css"/>
</head>

<body class="layui-layout-body">

<div class="layui-layout layui-layout-admin">

    <!-- 头部 -->
    @include("/common/_header.html"){}

    <!-- 侧边栏 -->
    @include("/common/_sidebar.html"){}

    <!-- 主体部分 -->
    @include("/common/_body.html"){}

    <!-- 底部 -->
    @include("/common/_footer.html"){}

</div>

<!-- 加载动画，移除位置在common.js中 -->
@include("/common/loading.html"){}

@/* 加入contextPath属性和session超时的配置 */
<script type="text/javascript">
    var Feng = {
        ctxPath: "",
        addCtx: function (ctx) {
            if (this.ctxPath === "") {
                this.ctxPath = ctx;
            }
        }
    };
    Feng.addCtx("${ctxPath}");
</script>
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js"></script>

<script>
    layui.use(['layer', 'element', 'admin', 'index'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var admin = layui.admin;
        var index = layui.index;
        $(document).on('click', '.layui-table-view .layui-table-body tr', function (event) {
            var trElem = $(this);
            var tableView = trElem.closest('.layui-table-view');
            tableView.find('.layui-table-body tr.table_tr_click').removeClass('table_tr_click');
            tableView.find('.layui-table-body tr[data-index="' + trElem.data('index') + '"]').addClass('table_tr_click');
        });


        // 默认加载主页
        index.loadHome({
            menuPath: '${ctxPath}/system/console',
            menuName: '<i class="layui-icon layui-icon-home"></i>'
        });

        // 修改密码点击事件
        $('#setPsw').click(function () {
            submit = 0;
            admin.open({
                id: 'pswForm',
                type: 2,
                title: 'Change password',
                shade: 0,
                content: '${ctxPath}/system/user_chpwd',
                end: function () {
                    if(submit == 1){
                        window.location.href = "${ctxPath}/logout";
                    }
                }
            });
        });

        // 退出登录点击事件
        $('#btnLogout').click(function () {
            layer.confirm('Confirm to log out and log in？', {
                title: 'Message',
                skin: 'layui-layer-admin',
                btn: ['Confirm', 'Cancel']
            }, function () {
                window.location.href = "${ctxPath}/logout";
            });
        });

        $.ajax({
            type: "POST",
            url: "${ctxPath}/mgr/getUser",
            dataType:'json',
            success: function (data) {
                submit = 0;
                if(data.lastLoginTime == ''){
                    admin.open({
                        id: 'pswForm',
                        type: 2,
                        title: '修改密码',
                        offset: "auto",
                        closeBtn: false, // 禁用默认关闭按钮
                        shade: 0.9, // 遮罩透明度
                        shadeClose: false, // 点击遮罩不关闭
                        content: '${ctxPath}/system/user_chpwd2',
                        end: function () {
                            if(submit == 1){
                                window.location.href = "${ctxPath}/logout";
                            }
                        }
                    });
                }
            }
        });
    });
</script>
</body>

</html>
